package com.eedi.framework.tenant.service;

import com.eedi.framework.common.exception.util.PreconditionsUtils;
import com.eedi.framework.tenant.controller.sys.vo.setup.SysSetupShortcutCreateReq;
import com.eedi.framework.tenant.controller.sys.vo.setup.SysSetupShortcutResp;
import com.eedi.framework.tenant.controller.sys.vo.setup.SysSetupShortcutUpReq;
import com.eedi.framework.tenant.dal.mapper.SysSetupShortcutMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

import static com.eedi.framework.tenant.enums.SysTenantErrorCodeConstants.SYS_Shortcut_NOT_EXISTS;

/**
 * 快捷方式
 *
 * @author zybourn
 */
@Service
@Slf4j
public class SysSetupShortcutServiceImpl implements SysSetupShortcutService {
    @Resource
    SysSetupShortcutMapper sysSetupShortcutMapper;

    @Override
    public void crate(SysSetupShortcutCreateReq req) {
        sysSetupShortcutMapper.insert(req);
    }

    @Override
    public void update(SysSetupShortcutUpReq req) {
        SysSetupShortcutResp sysSetupShortcut = sysSetupShortcutMapper.getById(req.getSysSetupShortcutId());
        PreconditionsUtils.checkNotNull(sysSetupShortcut, SYS_Shortcut_NOT_EXISTS);
        sysSetupShortcutMapper.update(req);
    }

    @Override
    public List<SysSetupShortcutResp> list() {
        return sysSetupShortcutMapper.list();
    }
}
